import { notFound } from "next/navigation"; import type { ReactNode } from "react"; import { api } from "@/lib/api"; import { CATEGORIES, FEED_CHANNELS } from "@websensor/core/client"; /** * Existence check outside the `loading.tsx` boundary so unknown category channels return a real 404 instead of a * 200 shell followed by the not-found UI (the page's own call is deduplicated by fetch memoization). */ export default async function CategoryLayout({ params, children }: { params: Promise<{ channel: string }>; children: ReactNode }) { const { channel } = await params; const ch = channel.toLowerCase(); if (!FEED_CHANNELS[ch] && !(CATEGORIES as readonly string[]).includes(ch) && !(await api.categoryDesk(ch))?.recent.length) notFound(); return children; }